import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;


public class CreateBWImage {

	public static void main(String[] args) throws IOException
	{
		//Read an image
		BufferedImage input = ImageIO.read(new File("C:/Program Files/MATLAB/R2012a/work/lenna1.jpg"));
		
		//Create a black -and-white image of the same size.
		BufferedImage im =
			new BufferedImage(input.getWidth(), input.getHeight(),BufferedImage.TYPE_BYTE_BINARY);
		
		//Get the graphics context for the black-and-white image
		Graphics2D g2d = im.createGraphics();
		
		//Render the input image on it.
		g2d.drawImage(input, 0, 0, null);
		
		//Store the resulting image using the JPG format.
    //rendered_lena.jpg Histogram_equlasition klasorunun altinda olacaktir. 
		ImageIO.write(im, "JPG", new File("rendered_lena.jpg"));
	}
}
